import router from "./router";
const whiteList = [
  "/home",
  "/detail",
  "/addTroops",
  "/user",
  "/evection",
  "/apply",
  "/model",
  "/modelDetail",
  "/log",
  "/addTemp",
  "/writeLog",
  "/permissionLog",
  "/readLogInfo",
];

router.beforeEach((to, from, next) => {
  if (whiteList.indexOf(to.path) !== -1) {
    document.title = to.meta.title;
    //// 如果是 iOS 设备，则使用如下 hack 的写法实现页面标题的更新
    //if (navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
    //  const hackIframe = document.createElement("iframe");
    //  hackIframe.style.display = "none";
    //  hackIframe.src = "/static/html/fixIosTitle.html?r=" + Math.random();
    //  document.body.appendChild(hackIframe);
    //  setTimeout((_) => {
    //    document.body.removeChild(hackIframe);
    //  }, 300);
    //}
    // 在免登录白名单，直接进入
    next();
  } else {
    next(`/home`); // 否则全部重定向到登录页
  }
});
